package cn.yusei.teamTribe.entity;

import cn.yusei.teamTribe.constant.SchoolCode;
import cn.yusei.teamTribe.util.StringUtil;

public class Team {

	private int id;
	private int schoolId;
	private String name;
	private String portrait;
	private int score;
	private String createTime;
	private String comment;
	private String wallpaper;
	
	public String getWallpaper() {
		return wallpaper;
	}
	public void setWallpaper(String wallpaper) {
		this.wallpaper = wallpaper;
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public int getSchoolId() {
		return schoolId;
	}
	public void setSchoolId(int schoolId) {
		this.schoolId = schoolId;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getPortrait() {
		return portrait;
	}
	public void setPortrait(String portrait) {
		this.portrait = portrait;
	}
	public int getScore() {
		return score;
	}
	public void setScore(int score) {
		this.score = score;
	}
	public String getCreateTime() {
		return createTime;
	}
	public void setCreateTime(String createTime) {
		this.createTime = createTime;
	}
	public String getComment() {
		return comment;
	}
	public void setComment(String comment) {
		this.comment = comment;
	}
	@Override
	public String toString() {
		return "Team [id=" + id + ", schoolId=" + schoolId + ", name=" + name + ", portrait=" + portrait + ", score="
				+ score + ", createTime=" + createTime + ", comment=" + comment + "]";
	}
	
	/**
	 * 添加社团的时候是否为合法的
	 * @return
	 */
	public boolean isInsertValid()
	{
		if(!SchoolCode.isSchoolCode(schoolId))
			return false;
		if(StringUtil.haveNullOrEmpty(name) || StringUtil.lengthAbove(name, 16))
			return false;
		if(comment == null || StringUtil.lengthAbove(comment, 21845))
			return false;
		return true;
	}
	
	/**
	 * 更新社团的时候是否合法
	 * @return
	 */
	public boolean isValid(){
		if(StringUtil.haveNullOrEmpty(name) || StringUtil.lengthAbove(name, 16))
			return false;
		if(comment == null || StringUtil.lengthAbove(comment, 21845))
			return false;
		if(portrait == null || portrait.length() != 32)
			return false;
		if(wallpaper == null || wallpaper.length() != 32){
			return false;			
		}
		return true;
	}
}
